/*
 * @Author: KKKKKK
 * @Date: 2021-01-10 12:08:53
 * @LastEditors: KKKKKK
 * @LastEditTime: 2021-01-10 12:08:54
 */
import axios from './config'
import url from './url'
const baseUrl = process.env.VUE_APP_BASE_URL

function dealParams (params) {
  const strArr = []
  for (const key in params) {
    strArr.push(`${key}=${params[key]}`)
  }
  return strArr.join('&')
}

// 登录
// 通过账号密码获取access_token接口
const getToken = (params) => axios.post(`${baseUrl}${url.login.oauth}?${dealParams(params)}`)

// 获取获取验证码
const getImgCode = (params) => axios({
  url: baseUrl + url.login.imgcode,
  method: 'get',
  params,
  responseType: 'blob'
})

export default {
  getToken,
  getImgCode
}
